<template>
  <div class="header">
    <img class="header-img" src="@/assets/img/bg_screen_header.png" alt="" />
    <div class="time">{{ time }}</div>
    <div class="text">xxx可视化大屏</div>
    <div class="return">
      <el-button type="success" @click="showAnimate()">过度动画</el-button>
      <img
        class="return-img"
        src="@/assets/img/ic_return.png"
        alt=""
        @click="returnHome"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref, onUnmounted } from "vue";
import { useRouter } from "vue-router";
import { getCurrentTime } from "js-eff-tool";

const router = useRouter();
const time = ref("");
let timer: any;
const emit = defineEmits(["showAnimate"]);
function returnHome() {
  router.push("/home");
}
function showAnimate() {
  emit("showAnimate");
}
onMounted(() => {
  timer = setInterval(() => {
    const { nowDay, nowDate } = getCurrentTime();
    time.value = nowDay + " " + nowDate;
  }, 1000);
});
onUnmounted(() => {
  clearInterval(timer);
});
</script>

<style lang="scss" scoped>
.header {
  width: 100%;
  height: 80px;
  position: relative;
  display: flex;
  padding: 0 1rem;
  box-sizing: border-box;
  color: #fff;

  .header-img {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    z-index: -1;
  }
  .time {
    width: 25%;
    display: flex;
    align-items: end;
    font-family: "fzcq";
    font-size: 1.5rem;
    letter-spacing: 2px;
  }
  .text {
    width: 50%;
    text-align: center;
    line-height: 90px;
    font-family: "fzgb";
    font-size: 1.5rem;
    font-weight: 700;
    // color: #85ffbd;
    letter-spacing: 4px;
  }
  .return {
    width: 25%;
    display: flex;
    align-items: end;
    justify-content: end;

    .return-img {
      height: 2.5rem;
      width: auto;
      cursor: pointer;
    }
  }
}
</style>